package com.dg.cuckoo.admin.action.basicInformation.permissionSettings;

import com.dg.cuckoo.admin.service.ProjectInfoServer;
import com.dg.cuckoo.admin.service.UsertoProjectService;
import com.dg.cuckoo.common.utils.PageModel;
import com.dg.cuckoo.core.BaseController;
import com.dg.cuckoo.core.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 基本资料-权限设置-用户对项目
 */
@RestController
@RequestMapping("/basicInformation/permissionSettings/userToProject")
public class UserToProject extends BaseController{

    @Autowired
    private UsertoProjectService service;
    @Autowired
    private ProjectInfoServer projectInfoServer;

    /**
     * 页面视图
     * @return
     */
    @PostMapping("view")
    public JsonResult<String> view(){
        String data = service.view();
        return new JsonResult<>(OK,data);
    }

    /**
     * 通过项目列表名称查看信息
     * @param name 项目列表名称
     * @return
     */
    @PostMapping("openInfoByname")
    public JsonResult<String> openInfoByname(String name){
        String data = service.openInfoByname(name);
        return new JsonResult<>(OK,data);
    }

    /**
     * 分页
     * @param page 页
     * @param pageSize 页数
     */
    @PostMapping("page")
    public JsonResult<PageModel> page(Integer page, Integer pageSize){
        PageModel data = projectInfoServer.page(page, pageSize);
        return new JsonResult<>(OK,data);
    }

    /**
     * 保存
     */
    @PostMapping("save")
    public JsonResult<Void> save(String username, List<String> list){
        service.save(username,list);
        return new JsonResult<>(OK);
    }

    /**
     * 搜索
     */
    @PostMapping("search")
    public JsonResult<List<String>> search(String search){
        List<String> data = service.search(search);
        return new JsonResult<>(OK,data);
    }

    /**
     * 点击用户名称显示已选项目
     */
    @PostMapping("viewpro")
    public JsonResult<List<String>> viewpro(String name){
        List<String> data = service.viewpro(name);
        return new JsonResult<>(OK,data);
    }



    /**
     * 点击显示二级标签
     */
    @PostMapping("openTwoLabel")
    public JsonResult<List<String>> openTwoLabel(String username){

        return new JsonResult<>(OK);
    }



}
